package com.twu.biblioteca.util;

import java.io.*;

public class IO {
    private  BufferedReader reader;
    private  BufferedWriter writer;

    public IO(BufferedReader reader, BufferedWriter writer) {
        this.reader = reader;
        this.writer = writer;
    }

    public  String readLine() {
        String str = null;
        try {
            str = reader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
            closeIn();
        }
        return str;
    }

    private  void closeIn() {
        try {
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public  void write(String str) {
        try {
            writer.write(str);
            writer.flush();
            newLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private  void newLine() {
        System.out.print(System.getProperty("line.separator"));
    }
}
